package max.ta.stock.plot;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.CandlestickRenderer;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.xy.DefaultHighLowDataset;

public class CandleStickChartPlotter
	extends AbstractFinancialChartPlotter {

    private static final long serialVersionUID = 1L;
    // --------------------------------------------------------------------------------
    // Renderer
    // --------------------------------------------------------------------------------
    private static final boolean DRAW_VALUME = false;

    public CandleStickChartPlotter(final String title) {
	super(title);
    }

    @Override
    protected JFreeChart createBaseChart(DefaultHighLowDataset dataset) {
	JFreeChart chart = ChartFactory.createCandlestickChart(title, "Time", "Price", dataset, LEGEND);
	final XYPlot plot = chart.getXYPlot();
	final XYItemRenderer renderer = plot.getRenderer();
	if (renderer instanceof CandlestickRenderer) {
	    CandlestickRenderer r = (CandlestickRenderer) renderer;
	    r.setDrawVolume(DRAW_VALUME);
	}
	return chart;
    }
}
